package app.modules.cloudpivot.organization;

import java.util.ArrayList;
import java.util.Map;

import com.authine.cloudpivot.engine.exceptions.DataSourceException;
import com.authine.cloudpivot.platform.organization.deprecated.RelatedCorpSettingModel;
import com.authine.cloudpivot.platform.organization.infrastructure.sync.customize.OrgSyncAdapterRuntimeFactory;
import com.authine.cloudpivot.platform.organization.infrastructure.sync.customize.OrgSyncAdapterRuntimeService;
import com.authine.cloudpivot.platform.organization.infrastructure.sync.customize.dto.OrgConfigMetaData;
import com.authine.cloudpivot.platform.organization.infrastructure.sync.customize.dto.OrgConfigParams;

/**
 * 自定义组织同步配置
 *
 * @author LiuGangQiang Create in 2024/04/12
 */
public class CustomOrgRuntimeFactory implements OrgSyncAdapterRuntimeFactory {

    @Override
    public OrgConfigMetaData getConfig() {
        OrgConfigMetaData metaData = new OrgConfigMetaData();
        metaData.setAdapterCode("EXPAND");
        metaData.setAdapterName("扩展组织");
        metaData.setConfigList(new ArrayList<>());
        metaData.getConfigList().add(OrgConfigParams.builder().code("require_param").description("必填参数").required(true).build());
        metaData.getConfigList().add(OrgConfigParams.builder().code("optional_param").description("可选参数").required(false).build());
        return metaData;
    }

    @Override
    public OrgSyncAdapterRuntimeService getRuntimeService(String corpId, Map<String, String> config) {
        return new CustomOrgRuntimeServiceImpl(corpId, config);
    }

    @Override
    public void registerCallBackUrl(RelatedCorpSettingModel relatedCorpSetting) throws DataSourceException {
        OrgSyncAdapterRuntimeFactory.super.registerCallBackUrl(relatedCorpSetting);
    }
    
}